# 导包

from api.EmployeeAPI import EmployeeAPI
from utils import common_assert
from utils import build_add_data
from utils import build_update_data
import unittest
from parameterized import parameterized

# 创建测试类
class TestEmployee(unittest.TestCase):
    # employee_id = None
    employee_id = 1288061322868658176

    # 前置处理
    def setUp(self):
        self.employee_api = EmployeeAPI()

    # 添加员工测试用例设计
    @parameterized.expand(build_add_data())
    def test01_add_employee(self,desc,add_employee_data):
        print(desc,add_employee_data)
        # 获取响应结果
        response = self.employee_api.add_employee(add_employee_data=add_employee_data)
        print(response.json())
        common_assert(self, response)  # 直接使用公共断言方法的默认值即可

        # 提取员工ID
        # TestEmployee.employee_id = response.json().get("data").get("id")
        # print(TestEmployee.employee_id)

    # 修改员工测试用例设计
    @parameterized.expand(build_update_data())
    def test02_update_employee(self,desc,update_data):
        print(desc,update_data)
        # 获取响应结果
        response = self.employee_api.updata_employee(TestEmployee.employee_id, updata_data=update_data)
        print(response.json())

        # 断言
        common_assert(self, response)  # 直接使用公共断言方法的默认值即可

    # 查询员工测试用例设计
    def test03_get_employee(self):
        # 获取响应结果
        response = self.employee_api.get_employee(TestEmployee.employee_id)
        # print(response.json())

        # 断言
        common_assert(self, response)  # 直接使用公共断言方法的默认值即可

    # 删除员工测试用例设计
    def test04_delete_employee(self):
        # 获取响应结果
        response = self.employee_api.delete_employee(TestEmployee.employee_id)
        # print(response.json())

        # 断言
        common_assert(self, response)  # 直接使用公共断言方法的默认值即可

